using UnityEngine;
using System.Collections;

public class ButtonControlLabelShow : MonoBehaviour {
	
	public UILabel label1;
	public UILabel label2;
	public UILabel label3;
	
	public string str1 = "";
	
	public string str2 = "";
	
	public string str3 = "";
	
	public string str4 = "";
	
	public string buttonString1 = "";
	
	public string buttonString2 = "";
	public string buttonString3 = "";
	public string buttonString4 = "";
	public string buttonString5 = "";
	
	public string buttonStringStatus1 = "";
	public string buttonStringStatus2 = "";
	public string buttonStringStatus3 = "";
	public string buttonStringStatus4 = "";
	public string buttonStringStatus5 = "";
	
	public GameObject closeTarget;
	
	int clickCount;

    GameObject door;

	// Use this for initialization
	void Start () {
		clickCount = 0;
		
		label1.text = str1;
		label2.text = buttonString1;
		label3.text = buttonStringStatus1;

        door = GameObject.Find("Door");
		
		if(TaskStatus.Instance().taskStatus == GameDefine.NPCStatus_CanSubmit){
			label2.text = buttonString1;
			label1.text = str1;
			label3.text = buttonStringStatus4;
			clickCount = 2;
		}
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	void OnClick(){
		/*
		if(clickCount == 0){
			label1.text = str2;
			label2.text = buttonString2;
			
			clickCount = 1;
		} else if(clickCount == 1){
			closeTarget.SetActive(false);
			
			label2.text = buttonString3;
			
			//ModelLocator.getInstance().dispacthEvent(ClientToClientFlag.CLIENT_TASK_ONE_STATUS,new object[]{GameDefine.NPCStatus_UnComplete});
			TaskStatus.Instance().taskStatus = GameDefine.NPCStatus_UnComplete;
           
            SceneClickLogic.getInstance().dispatchSceneObjClick(door);
			
			clickCount = 2;
		} else if(clickCount == 2 && TaskStatus.Instance().taskStatus == GameDefine.NPCStatus_CanSubmit){
			label2.text = buttonString4;
			
			TaskStatus.Instance().taskStatus = GameDefine.NPCStatus_SubmitOrNoTask;
			closeTarget.SetActive(false);
			clickCount ++;
		} else if(clickCount == 3){
			label2.text = buttonString5;
			
			closeTarget.SetActive(false);
		} else {
			closeTarget.SetActive(false);
            SceneClickLogic.getInstance().dispatchSceneObjClick(door);
		}
		*/
		
		if(TaskStatus.Instance().taskStatus == GameDefine.NPCStatus_TaskAccept){
			if(clickCount == 0){
				label1.text = str2;
				label2.text = buttonString2;
				label2.color = new Color(62 / 255.0f,1,77 / 255.0f,1);
				label3.text = buttonStringStatus2;
				
				clickCount = 1;
			} else {
				closeTarget.SetActive(false);
				
				GameObject go = GameObject.Find("Task_01");
				GuideLogic guide = Camera.main.GetComponent<GuideLogic>();
				GameObject guideMark = GameObject.Find("GuideArrow_Left");
				guide.guideMark = guideMark.transform;
				guide.setGuidePos(go,3,new Vector3(155,0,0));
				
				label1.text = str3;
				label2.text = buttonString3;
				label2.color = Color.white;
				label3.text = buttonStringStatus3;
				
				TaskStatus.Instance().taskStatus = GameDefine.NPCStatus_UnComplete;
           
            	SceneClickLogic.getInstance().dispatchSceneObjClick(door);
				clickCount = 1;
			}
		} else if(TaskStatus.Instance().taskStatus == GameDefine.NPCStatus_UnComplete){
			closeTarget.SetActive(false);
		} else if(TaskStatus.Instance().taskStatus == GameDefine.NPCStatus_CanSubmit){
			if(clickCount == 2) {
				label2.text = buttonString5;
				label2.color = new Color(62 / 255.0f,1,77 / 255.0f,1);
				label1.text = str4;
				label3.text = buttonStringStatus2;
				
				clickCount++;
			} else{
				label1.text = str1;
				label2.text = buttonStringStatus2;
				label3.text = buttonStringStatus2;
				
				
				TaskStatus.Instance().taskStatus = GameDefine.NPCStatus_SubmitOrNoTask;
				
				closeTarget.SetActive(false);
			}
		} else {
			label1.text = str1;
			label2.text = buttonStringStatus2;
			label3.text = buttonStringStatus2;
			
			closeTarget.SetActive(false);
		}
	}
}
